package com.luom.fsp.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.luom.fsp.model.dto.order.OrderAllQueryRequest;
import com.luom.fsp.model.dto.order.OrderAllQueryResult;
import com.luom.fsp.model.entity.Order;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.luom.fsp.model.vo.OrderStatsVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
* @author 28713
* @description 针对表【order(订单表)】的数据库操作Mapper
* @createDate 2025-01-25 22:00:47
* @Entity com.luom.fsp.model.entity.Order
*/
public interface OrderMapper extends BaseMapper<Order> {

    /**
     * 获取订单列表
     * @return
     */
    Page<OrderAllQueryResult> queryOrders(@Param("page") Page<OrderAllQueryResult> page,@Param("query") OrderAllQueryRequest query);

    @Select("SELECT DATE(createTime) AS date, COUNT(id) AS orderCount " +
            "FROM orders " +
            "WHERE createTime >= #{start} AND createTime < #{end} " +
            "AND isDelete = 0 " +
            "GROUP BY DATE(createTime)")
    List<OrderStatsVO> selectDailyOrders(@Param("start") Date start, @Param("end") Date end);


    List<OrderStatsVO> selectDailyOrdersByDates(@Param("dates") List<String> dates);

}




